libname bond 'D:\name your local directory';
libname factor 'D:\name your local directory\Ken French Data Library';

***************************************************************************************************************************************************
*Add the MKTBond factor to the rolling data to estimate Beta^MKT
***************************************************************************************************************************************************;

%LET IN1  =MKTbond;
%LET IN2  =LTBRoll36_24;
%LET OUT =LTBRoll36Factors_24;


proc sql;
create table LTBRoll36Factors_24 as select a.*, b.MKTBond, b.rf
from bond.&IN2 as a left join bond.&IN1 as b
on a.yyyymm=b.yyyymm;
quit;


proc sort data=LTBRoll36Factors_24;
by complete_cusip date descending rankdate;
run;

data bond.&OUT;
set LTBRoll36Factors_24;
run;
